﻿//
// *************************************************************************************
// WP-Framework
// 
// Developed by
// Lukas Kretschmar (lkretschmar.dev@bluewin.ch)
//
// Switzerland, Copyright (c) 2013 lkretschmar
// This content is released under the MIT License (http://opensource.org/licenses/MIT).
//     
// *************************************************************************************
//
//
			

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using KretschIT.WP_Fx.EasyMoq.Generator;
using System.Linq;
using KretschIT.WP_Fx.EasyMoq.Generator.Configurations;
using System.Reflection;
using KretschIT.WP_Fx.Testing;

namespace KretschIT.WP_Fx.EasyMoq.Generator.Tests
{
    [TestClass]
    public class EasyMoqTemplateHelperTest
    {
        private IEasyMoqTemplateHelper helper;

        [TestInitialize]
        public void Init()
        {
            var configReader = new EasyMoqClassConfigReader(Assembly.GetExecutingAssembly());
            this.helper = new EasyMoqTemplateHelper(configReader);
        }

        [TestMethod]
        public void Test_EasyMoqTemplateHelperCtor()
        {
            var configReader = new EasyMoqClassConfigReader(Assembly.GetExecutingAssembly());
            new EasyMoqTemplateHelper(configReader);
        }

        [TestMethod]
        public void Test_EasyMoqTemplateHelperCtor_NullArgument()
        {
            ExceptionAssert.Throws<ArgumentNullException>(() =>
                {
                    new EasyMoqTemplateHelper(null);
                });
        }

        [TestMethod]
        public void Test_RegistrationAttributeName()
        {
            Assert.AreEqual("EasyMoqRegistration", this.helper.RegistrationAttributeName);
        }

        [TestMethod]
        public void Test_InitClassName()
        {
            Assert.AreEqual("EasyMoqInit", this.helper.InitClassName);
        }
        
        [TestMethod]
        public void Test_MockableInfo()
        {
            Assert.IsNotNull(this.helper.MockableInfo);
            Assert.AreEqual(11, this.helper.MockableInfo.Count());
        }

        [TestMethod]
        public void Test_TargetNamespace()
        {
            Assert.AreEqual("KretschIT.WP_Fx.EasyMoq.Generator.Tests", this.helper.TargetNamespace);
        }

        [TestMethod]
        public void Test_FactoryUsingNamespaces()
        {
            Assert.IsNotNull(this.helper.FactoryUsingNamespaces);
            Assert.AreEqual(5, this.helper.FactoryUsingNamespaces.Count());
        }

        [TestMethod]
        public void Test_MockablesUsingNamespaces()
        {
            Assert.IsNotNull(this.helper.MockablesUsingNamespaces);
            Assert.AreEqual(6, this.helper.MockablesUsingNamespaces.Count());
        }

        [TestMethod]
        public void Test_NoDoubleNamespaces()
        {
            var factoryNamespaces = this.helper.FactoryUsingNamespaces;
            var mockablesNamespaces = this.helper.MockablesUsingNamespaces;
            var count = factoryNamespaces.Count() + mockablesNamespaces.Count();
            Assert.AreEqual(count, factoryNamespaces.Union(mockablesNamespaces).Count());
        }
    }
}
